function main() {

    function upInsert() {
        const data = payload.get().body.toObject()
        // 查询是否已存在
        const sqlSelect = `SELECT * FROM oa_pm_project_budget WHERE sub_id = '${data.sub_id}' AND project_id = '${data.project_id}';`
        const selectRes = SQL.query(DB_NAME, sqlSelect)
        if (selectRes && selectRes.length) {
            const sqlUpdate = `UPDATE oa_pm_project_budget
        SET project_name = '${data.project_name}', net_value = ${data.net_value}, tax_value = ${data.tax_value}, tip = '${data.tip}'
        WHERE sub_id = '${data.sub_id}' AND project_id = '${data.project_id}'`

            const updateRes = SQL.exec(DB_NAME, sqlUpdate)
            if (updateRes) {
                return okMsg(updateRes)
            } else {
                return errMsg(insertRes)
            }
        }
        const sqlInsert = `INSERT INTO oa_pm_project_budget (sub_id, project_id, project_name, net_value, tax_value, tip) VALUES (?, ?, ?, ?, ?, ?)`
        const insertRes = SQL.exec(DB_NAME, sqlInsert, ...[data.sub_id, data.project_id, data.project_name, data.net_value, data.tax_value, data.tip])
        if (insertRes) {
            return okMsg(insertRes)
        } else {
            return errMsg(insertRes)
        }
    }
    switch (payload.get().method) {
        case 'POST':
            return upInsert()
    }


}
